<template>
  <page-header-wrapper>
    <a-card :bordered="false">
      <div class="gtitle" style="margin-bottom: 20px"><a-icon type="info-circle" style="color: #108ee9" theme="filled"/>系统运行状态监视</div>

      <div class="rowtxt">
        <a-row class='rowmb'>
          <a-col :span="2">CPU使用率:</a-col>
          <a-col :span="4" class="blue">23%</a-col>
          <a-col :span="2" :offset="16"><a-button type="primary"><a-icon type="sync" />刷新</a-button></a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="2">内存总大小:</a-col>
          <a-col :span="4" class="blue">8192MB</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="2">内存使用率:</a-col>
          <a-col :span="4" class="blue">47%</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="2">磁盘总空间:</a-col>
          <a-col :span="4" class="blue">9682GB</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="2">磁盘剩余空间:</a-col>
          <a-col :span="4" class="blue">4982GB</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="2">磁盘使用率:</a-col>
          <a-col :span="4" class="blue">46%</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="2">磁盘使用率:</a-col>
          <a-col :span="4" class="blue">46%</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="2">网络IO（IN）:</a-col>
          <a-col :span="4" class="blue">4.86Mbps</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="2">网络IO（OUT）:</a-col>
          <a-col :span="4" class="blue">282.5Mbps</a-col>
        </a-row>
      </div>


      <div class="gtitle" style="margin-bottom: 20px;margin-top: 20px"><a-icon type="info-circle" style="color: #108ee9" theme="filled"/>系统运行状态监视</div>
      <div class="rowtxt">
        <a-row class='rowmb'>
          <a-col :span="2">系统当前时间:</a-col>
          <a-col :span="4" class="blue">{{moment(systermtime).format('YYYY-MM-DD HH:mm:ss')}}</a-col>
          <a-col :span="2" >
            <div style="overflow: hidden;position: relative;">
              <a-button type="primary" @click="modifysystermtime()" style="width: 100%">修改</a-button>
              <a-date-picker
                format="YYYY-MM-DD HH:mm:ss"
                ref="timeselect"
                style="opacity: 1;cursor: pointer;position: absolute;left: 0;top:0;opacity: 0"
                :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }"
              />
            </div>
          </a-col>
        </a-row>

        <a-row class='rowmb'>
          <a-col :span="2">是否开启自动同步:</a-col>
          <a-col :span="4"><a-switch checked-children="是" un-checked-children="否" /></a-col>
        </a-row>

        <a-row class='rowmb'>
          <a-col :span="2">NTP服务器:</a-col>
          <a-col :span="4"><a-input placeholder="ntp.ntsc.ac.cn"></a-input></a-col>
        </a-row>
      </div>

      <div class="gtitle" style="margin-bottom: 20px;margin-top: 20px"><a-icon type="info-circle" style="color: #108ee9" theme="filled"/>系统服务配置</div>
      <div class="rowtxt">
        <a-row class='rowmb'>
          <a-col :span="2">SSH服务:</a-col>
          <a-col :span="4"><a-switch checked-children="开" un-checked-children="关" /></a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="2">ICMP服务:</a-col>
          <a-col :span="4"><a-switch checked-children="开" un-checked-children="关" /></a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="2">防火墙服务:</a-col>
          <a-col :span="4"><a-switch checked-children="开" un-checked-children="关" /></a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="2">禁止访问地址:</a-col>
          <a-col :span="4"><a-input placeholder="请输入IP地址，IP段或IP掩码" v-model="ipinput"></a-input></a-col>
          <a-col :span="2" :offset="1"><a-button type="primary" @click="addip()">添加</a-button></a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="4" :offset="2">
            <div class="iplist">
              <div v-for="(item2,index) in ipjson.ip">
                {{item2.value}}
                <a-icon type="delete" class="icon" @click="deleteip(index)"/>
              </div>
            </div>
          </a-col>
        </a-row>
      </div>

      <div class="gtitle" style="margin-bottom: 20px;margin-top: 20px"><a-icon type="info-circle" style="color: #108ee9" theme="filled"/>系统运行管理</div>
      <div class="rowtxt">
        <a-row class='rowmb'>
          <a-col :span="2">WEB应用服务:</a-col>
          <a-col :span="4"><a-button type="primary">重启</a-button></a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="2">系统主服务:</a-col>
          <a-col :span="4"><a-button type="primary">重启</a-button></a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="2">网卡服务:</a-col>
          <a-col :span="4"><a-button type="primary">重启</a-button></a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="2">平台主机服务:</a-col>
          <a-col :span="2"><a-button type="primary">重启</a-button></a-col>
          <a-col :span="2"><a-button type="primary">关机</a-button></a-col>
        </a-row>
      </div>
    </a-card>
  </page-header-wrapper>
</template>

<script>
  import {} from '../../utils/constant'
  import moment from 'moment';
  export default {
    name: 'PatchUpdateManage',
    data() {
      return {
        systermtime:'',
        ipinput:'',
        ipjson:{
          ip:[]
        }
      }
    },
    mounted() {
      this.loadtime()
    },
    methods:{
      moment,
      loadtime(){
        this.systermtime = new Date().getTime()
        setInterval(()=>{
          this.systermtime += 1000
        },1000)
      },
      addip(){
        if(this.ipinput){
          let array = this.ipinput.split('.')
          if(array.length < 3){
            this.$message.error('格式不正确')
            return
          }

          let json = {}
          if(this.ipinput.indexOf('-')>-1){
            json.type = 3
          }else if(this.ipinput.indexOf('/')>-1){
            json.type = 2
          }else{
            json.type = 1
          }
          json.value = this.ipinput
          this.ipjson.ip.push(json)
          this.ipinput = ''
        }
      },
      deleteip(index){
        this.ipjson.ip.splice(index,1)
      },

    }
  }
</script>

<style lang="less"  scoped>

  .gtitle{
    background-color: #e6f3fc;
    line-height: 40px;
    padding-left: 20px;
    color: #333;
    font-weight: bold;

    i{
      margin-right: 10px;
    }
  }
  .rowtxt,.ant-radio-group{
    line-height: 32px;

  }
  .ant-radio-group{
    width: 100%;
  }
  .rowspan{
    display: inline-block;
    width: 150px;
  }
  .showtxt{
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0 10px;
    height: 120px;
    overflow-y: auto;
  }
  .rowmb{
    margin-bottom: 10px;
  }
  .blue{
    color: #3366FF;
  }
  .iplist{
    border: 1px solid #ddd;
    padding: 5px;
    min-height: 100px;
    line-height: 30px;
    div:hover{
      background-color: #efefef;
    }
    .icon{
      color: red;
      cursor: pointer;
      line-height: 30px;
      float: right;
      margin-right: 20px;
    }
  }
</style>
